﻿#include "BuckMain.h"
#include "src/frend/uilogin/LoginDialog.h"
#include "src/frend/uimain/toolbarwidget.h"
#include <QDebug>
BuckMain::BuckMain(QWidget* parent)
    : QWidget(parent)
    , ui(new Ui::BuckMainClass())
{
    ui->setupUi(this);
    ui->splitter->setStretchFactor(0, 1);
    ui->splitter->setStretchFactor(1, 4);
    connect(ui->toolBar_widget, &ToolBarWidget::buttonClicked, this, &BuckMain::onButtonClicked);
}
void BuckMain::onButtonClicked(const QString& text)
{
    /*QString str  = QString::fromLocal8Bit("退出登录");
    QString str1 = text;
    bool    s    = str.compare(str1);*/

    if (text.compare(QString::fromLocal8Bit("退出登录"))) { showLoginDialog(); }
}
BuckMain::~BuckMain()
{
    delete ui;
}

void BuckMain::showLoginDialog()
{
    if (m_loginDialog == nullptr) {
        m_loginDialog = new LoginDialog();

        m_loginDialog->updateLoginInfo();
        connect(m_loginDialog, &LoginDialog::accepted, this, &BuckMain::show);
    }
    hide();
    m_loginDialog->show();
}
